feat(finops): add bounded usage evidence authority - #315
seonghobae wants to merge 11 commits into
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Fresh gate refresh (2026-08-28): keep this PR Draft and unchanged at exact contributor head Two control-plane facts have materially changed since the body snapshot:
Fresh pg-side state is otherwise unchanged: #233 remains the earliest repo-wide coverage dependency; this PR has no formal reviews or review threads; current CI is still non-passing at the repository-wide 100% gate while Release Acceptance is success. Do not churn source, duplicate #233, mark Ready, or rerun old evidence as if it used newer central workflow code. Re-evaluate only after material protected-central or #233 change. |
|
2026-09-18 exact-head evidence refresh: |
Addresses #312 through the existing bounded usage-evidence authority lane. This remains a Draft child of dependency-root #233; protected
mainis not written directly.Exact stack
main:5913c4bad79d6bc29d7cc1c624abb7db2ea6a77cat the latest verified sweep;01d231fde23b82e2ced258d7bfcb4721ed75706d;de5cca77f556b4a2126d8e15f00aa1194e8cd75c;157d0ac9dcf23a54a05d010044344e0f650b8698;pg_llm_batch/usage_evidence.py,tests/test_usage_evidence.py, andtests/test_usage_evidence_json_interoperability.py.Measurement-completeness contract retained
The earlier primitive preserved provenance authority but nullable token dimensions could not losslessly distinguish measured zero from unavailable/unknown usage, nor represent partial or mixed reconciled aggregates. Test-first
040f9d9e07373f9ab9cb68ac532b0e451e0d415destablished that ambiguity and production38ecfd8ab7509ee59edc1241b5a79ab6042691fcadded the pg-ownedUsageCompletenessvocabulary (COMPLETE,PARTIAL,UNAVAILABLE,MIXED) and the count/completeness invariant.UNAVAILABLErequires a null count; every available state requires an explicit bounded non-negative count. Provenance remains separately owned byUsageAuthority.That predecessor generation was repository-local GREEN, but its receipts do not transfer to later heads.
Executed JSON integer interoperability RED
Test-only
de5cca77f556b4a2126d8e15f00aa1194e8cd75cadded focused regressions requiringrequest_count,input_token_count, andoutput_token_countto reject2**53while accepting and JSON-round-tripping2**53 - 1, with production still using_MAX_COUNT = 2**63 - 1.That exact head produced genuine hosted RED:
35550023971: completed / failure;35550024233: completed / success;Run unit testson the exact source head;This is source-contract RED rather than runner/queue/container failure. It proves the public canonical-JSON evidence contract still admitted integers above the cross-implementation exact-integer interoperability ceiling.
Minimum causal repair
Ordinary-forward
157d0ac9dcf23a54a05d010044344e0f650b8698applies only the repair required by that RED:_MAX_COUNTnarrows from2**63 - 1to2**53 - 1;intadmission, non-negativity, completeness invariants, deterministic canonical JSON, SHA-256 identity, bounded identifiers, and the content-minimal evidence surface are unchanged.PostgreSQL signed
BIGINTremains sufficient storage capacity; it is no longer treated as the semantic maximum of a cross-system JSON evidence contract. RFC 8259 §6 is the interoperability basis, not a claim that JSON syntax forbids larger integers.Exact-current repository acceptance
Exact
157d0ac9dcf23a54a05d010044344e0f650b8698has now reacquired its own repository-local evidence:35581365862: completed / success. Exact-source verification, Python 3.10/3.12/3.14 unit lanes, container/PostgreSQL runtime smokes, compile, Ruff, public-docstring enforcement, line/branch coverage gate, lock freshness, and distribution build all completed successfully.35581366002: completed / success. The workflow checked out the exact PR head, materialized two clean exact-head source trees, built wheel/sdist twice, verified artifact identity, and preserved bounded release evidence.This closes the branch-local JSON-interoperability RED -> minimum repair -> exact-head GREEN loop. It does not establish independent approval, protected-main integration, current central Security/SAST/model-backed acceptance, immutable release authority, or pricing/provider truth. Keep Draft.
Product / integration boundary
This slice remains evidence accounting, not pricing arithmetic, billing settlement, provider certification, or proof that reconciliation itself is correct. #318 owns future released-Contextual-Orchestrator ACL mapping and must preserve unavailable/unknown and completeness/provenance semantics rather than infer them from nullable counts or a mutable upstream enum.
After #233 reaches protected main, reconcile this child non-destructively onto the then-current protected base and reacquire every exact-final-head/current-base CI/security/SAST/coverage/docstrings/PostgreSQL/package/SBOM/provenance/release/review/thread gate required by live governance. Mutable central state belongs in #244 and live owner PRs.
Reference: Bray, T. (2017). The JavaScript Object Notation (JSON) Data Interchange Format (RFC 8259). Internet Engineering Task Force. https://doi.org/10.17487/RFC8259
No force push, destructive rebase, protected-main direct write, self-approval, gate weakening, fabricated review, mutable sibling dependency adoption, predecessor-evidence transfer, blind rerun, source-neutral wake commit, or branch-only release claim is authorized.